<template>
	<view class="j-message-details">
		<view class="j-message-box">
			<view class="j-message-title">{{ messageInfo.msgTitle ? messageInfo.msgTitle : '' }}</view>
			<view class="j-message-time">{{ messageInfo.createTime ? messageInfo.createTime : '' }}</view>
		</view>
		<view class="j-message-content">{{ messageInfo.msgContent ? messageInfo.msgContent : '' }}</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			messageInfo: {},
			params: {
				messageId: ''
			}
		};
	},
	onLoad(e) {
		this.params.messageId = e.messageId;
		// 查询详情
		this.postGetInfo();
		// 标记已读
		this.postReadMessage();
	},
	methods: {
		// 消息-查询详情
		postGetInfo() {
			this.$u.api
				.postGetInfo(this.params)
				.then(res => {
					console.log(res, '[消息详情页-查询消息详情]');
					if (res.data) {
						this.messageInfo = res.data;
					}
				})
				.catch(err => {
					console.log(err);
				});
		},
		// 消息-读取消息
		postReadMessage() {
			this.$u.api
				.postReadMessage(this.params)
				.then(res => {
					console.log(res, '[消息详情页-读取消息]');
				})
				.catch(err => {
					console.log(err);
				});
		}
	}
};
</script>

<style scoped lang="scss">
.j-message-box {
	margin-top: 40rpx;
	display: flex;
	align-items: center;
	flex-direction: column;
	justify-content: center;

	.j-message-title {
		font-size: 34rpx;
		font-weight: bold;
	}

	.j-message-time {
		font-size: 24rpx;
		color: #909399;
	}
}
.j-message-content {
	margin-top: 40rpx;
	padding: 0 25rpx;
}
</style>
